package top.kaoshanji.r2ch07b;

/**
 * 代码清单-r2ch07b-223页b：计算方法执行时间
 * @author kaoshanji
 * ^_^
 * create time 2025/5/7 11:17
 */
public class MethodPerformance {

    private long begin;
    private long end;
    private String serviceMethod;

    public MethodPerformance(String serviceMethod) {
        reset(serviceMethod);
    }

    public void reset(String serviceMethod) {
        this.serviceMethod = serviceMethod;
        this.begin = System.currentTimeMillis();
    }

    public void printPerformance() {
        end = System.currentTimeMillis();
        long elapse = end - begin;
        System.out.println(serviceMethod + " 方法花费：" + elapse + " 毫秒...");
    }


}
